package com.zhong.gang.applib.base.fm;

import androidx.databinding.ViewDataBinding;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;

public abstract class FmBaseRefreshNotRecycerlerView<T extends ViewDataBinding>
        extends FmBase<T> implements OnRefreshListener {
    public SmartRefreshLayout swipeRefreshLayout;

    @Override
    public boolean showLoading() {
        return true;
    }

    public void initrefrsh(SmartRefreshLayout swipeRefreshLayout){
        this.swipeRefreshLayout = swipeRefreshLayout;
        if (swipeRefreshLayout != null) {
            swipeRefreshLayout.setOnRefreshListener(this);
        }
    }

    @Override
    public void onRefresh(RefreshLayout refreshLayout) {
        getData();
    }

    public void closeRefresh(){
        if (swipeRefreshLayout != null)
            swipeRefreshLayout.finishRefresh(true);
    }
}
